﻿/*
 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

#ifndef RMDA_TIME_STRU_H
#define RMDA_TIME_STRU_H

#include "BurnToolCommon/StdAfx.h"
#include "BurnToolCommon/sop_errno.h"

class RMDA_TIME_STRU {
public:
    RMDA_TIME_STRU();

    explicit RMDA_TIME_STRU(S64 sllYearBegin);
    ~RMDA_TIME_STRU() {}

    BOOL operator == (const RMDA_TIME_STRU &other);
    BOOL operator != (const RMDA_TIME_STRU &other);
    BOOL operator < (const RMDA_TIME_STRU &other);
    BOOL operator <= (const RMDA_TIME_STRU &other);
    BOOL operator > (const RMDA_TIME_STRU &other);
    BOOL operator >= (const RMDA_TIME_STRU &other);

    // 直接减法返回整数（毫秒）
    S64 operator - (const RMDA_TIME_STRU &other);

    void GetHostDateTime();
    S64 GetValMilliSec() const;
    void SetValMilliSec(S64 sllMilliSecAll);

    S64 GetDaysOfAYear(S64 sllYear) const;                      // 取某年的天数
    static S64 GetDaysOfAMonth(S64 sllMonth, BOOL bLeap); // 取某月的天数

    S64 Year2Day(const S64 sllYear) const;                      // 年数化为天数,以公元元年为起点
    static S64 Month2Day(S64 sllMonth, BOOL bLeap); // 一年前nMonth个月的天数，小于一年

    U32 Day2YearMonthDay(S64 sllDayAll, S64 &sllYear, S64 &sllMonth, S64 &sllDay) const;
    static U32 Day2MonthDay(S64 sllDayAll, S64 &sllMonth, S64 &sllDay, BOOL bLeap);
    static BOOL IsLeapYear(const S64 sllYear);                                   // 是否闰年
    QString FormatDayTimeToColonStr(BOOL bIncludeMilliSec = TRUE) const;

private:
    S64 m_sllYearBegin{0}; // 年份起点
    U32 ulDate{0};         // 年月日
    U32 ulTime{0};         // 时分秒毫秒
};

#endif

